package com.wuercloud.swagger;
/*package com.wuercloud.swagger;

import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.http.HttpHeaders;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.AuthCache;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.HttpClient;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.impl.auth.BasicScheme;
import org.apache.http.impl.client.BasicAuthCache;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.message.BasicHeader;
import org.apache.http.protocol.HttpContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriUtils;

import com.fasterxml.jackson.annotation.JsonInclude;

@Component
public class UnClient {
	@Autowired
	private RestTemplate rt;
	private URI rootUri;

	public UnClient(String url, String username, String password) throws MalformedURLException, URISyntaxException {
		this(new URL(url), username, password);
	}

	private UnClient(URL url, String username, String password) throws MalformedURLException, URISyntaxException {
		this.rootUri = url.toURI();
		this.rt = new RestTemplate(getRequestFactory(url, username, password));
		this.rt.setMessageConverters(getMessageConverters());
	}

	public void UnBindQueue(String vhost, String queue, String exchange, String routingKey) {
		if (vhost == null || vhost.isEmpty()) {
			throw new IllegalArgumentException("vhost cannot be null or blank");
		}
		if (queue == null || queue.isEmpty()) {
			throw new IllegalArgumentException("queue cannot be null or blank");
		}
		if (exchange == null || exchange.isEmpty()) {
			throw new IllegalArgumentException("exchange cannot be null or blank");
		}
		if (routingKey == null || routingKey.isEmpty()) {
			throw new IllegalArgumentException("routingKey cannot be null or blank");
		}

		final URI uri = uriWithPath("./bindings/" + encodePathSegment(vhost) + "/e/" + encodePathSegment(exchange)
				+ "/q/" + encodePathSegment(queue) + "/" + encodePathSegment(routingKey));
		this.rt.delete(uri);
	}

	private String encodePathSegment(final String pathSegment) {
		try {
			return UriUtils.encodePathSegment(pathSegment, "UTF-8");
		} catch (UnsupportedEncodingException e) {
			return pathSegment;
		}
	}

	private URI uriWithPath(final String path) {
		return this.rootUri.resolve(path);
	}

	private List<HttpMessageConverter<?>> getMessageConverters() {
		List<HttpMessageConverter<?>> xs = new ArrayList<HttpMessageConverter<?>>();
		final Jackson2ObjectMapperBuilder bldr = Jackson2ObjectMapperBuilder.json()
				.serializationInclusion(JsonInclude.Include.NON_NULL);
		xs.add(new MappingJackson2HttpMessageConverter(bldr.build()));
		return xs;
	}

	private HttpComponentsClientHttpRequestFactory getRequestFactory(final URL url, final String username,
			final String password) throws MalformedURLException {
		String theUser = username;
		String thePassword = password;
		String userInfo = url.getUserInfo();
		if (userInfo != null && theUser == null) {
			String[] userParts = userInfo.split(":");
			if (userParts.length > 0) {
				theUser = userParts[0];
			}
			if (userParts.length > 1) {
				thePassword = userParts[1];
			}
		}
		final HttpClientBuilder bldr = HttpClientBuilder.create()
				.setDefaultCredentialsProvider(getCredentialsProvider(url, theUser, thePassword));
		bldr.setDefaultHeaders(Arrays.asList(new BasicHeader(HttpHeaders.CONTENT_TYPE, "application/json")));

		HttpClient httpClient = bldr.build();

		// RabbitMQ HTTP API currently does not support challenge/response for
		// PUT methods.
		AuthCache authCache = new BasicAuthCache();
		BasicScheme basicScheme = new BasicScheme();
		authCache.put(new HttpHost(rootUri.getHost(), rootUri.getPort(), rootUri.getScheme()), basicScheme);
		final HttpClientContext ctx = HttpClientContext.create();
		ctx.setAuthCache(authCache);
		return new HttpComponentsClientHttpRequestFactory(httpClient) {
			@Override
			protected HttpContext createHttpContext(HttpMethod httpMethod, URI uri) {
				return ctx;
			}
		};
	}

	private CredentialsProvider getCredentialsProvider(final URL url, final String username, final String password) {
		CredentialsProvider cp = new BasicCredentialsProvider();
		cp.setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT),
				new UsernamePasswordCredentials(username, password));

		return cp;
	}
}
*/